Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tst_Parser: replace Q_ASSERT(false) with Q_UNREACHABLE() #271

Conversation

thiagomacieira
Copy link
Member

Q_ASSERT() disappears in release mode, leading Clang to print a static analysis warning about an impossible condition:

tst_parser.cpp:251:16: warning: variable 'err' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
  251 |     } else if (ourType == CborTextStringType) {
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tst_parser.cpp:263:12: note: uninitialized use occurs here
  263 |     return err;
      |            ^~~
tst_parser.cpp:251:12: note: remove the 'if' if its condition is always true

Q_UNREACHABLE() becomes a plain __builtin_unreachable() in release mode.

`Q_ASSERT()` disappears in release mode, leading Clang to print a static
analysis warning about an impossible condition:
```
tst_parser.cpp:251:16: warning: variable 'err' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
  251 |     } else if (ourType == CborTextStringType) {
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tst_parser.cpp:263:12: note: uninitialized use occurs here
  263 |     return err;
      |            ^~~
tst_parser.cpp:251:12: note: remove the 'if' if its condition is always true
```

`Q_UNREACHABLE()` becomes a plain `__builtin_unreachable()` in release
mode.

Signed-off-by: Thiago Macieira <[email protected]>
@thiagomacieira thiagomacieira force-pushed the tst_Parser_replace_Q_ASSERT_false_with_Q_UNREACHABLE_ branch from 9af58a5 to 4f2c293 Compare February 13, 2025 22:55
@thiagomacieira thiagomacieira merged commit 53ff130 into intel:main Feb 14, 2025
6 checks passed
@thiagomacieira thiagomacieira deleted the tst_Parser_replace_Q_ASSERT_false_with_Q_UNREACHABLE_ branch February 14, 2025 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants